from tools import conMysql
import xlwt
import time


con = conMysql('47.94.144.144', 'appuser', 'appuser007', 'tiantian_v2', 3306)
res = con.executeSelectSql('select * from tiantian_v2.tt_channel_company;')
print(res)
print(len(res))

book = xlwt.Workbook()
sheet = book.add_sheet('sheet1')

title = ['id', 'company_name', 'name', 'status', 'password', 'view_permisson', 'permisson', 'h5_register', 'loan_amount', 'order_number', 'loan_number', 'create_time', 'update_time']
i = 0
for t in title:
    sheet.write(0,i,t)
    i+=1

for d in range(len(res)):
    for j in range(len(res[d])):
        sheet.write(d+1, j, res[d][j])

now_time = time.strftime('%y%m%d%H%M%S', time.localtime())

book.save('%s授权情况.xls'%now_time)






